<?php

namespace  app\command\controller;

use common\model\sell66\UserOrder;
use common\model\sell66\BotInv;
use think\Exception;

/**
 * 清理过期CD TIME
 * 
 * @author zhouqiang
 * @date 2018-06-04
 */
class CleanCdTime
{
	/**
	 * 获取过期CD时间数量
	 * @return int
	 */
	protected function getExpiredCdTotals()
	{
		return BotInv::getExpiredCdTotals();
	}

	/**
	 * 处理CD时间
	 * @return int
	 */
	protected function cleanCdTime()
	{
		return BotInv::cleanCdTime();
	}

	public function expired()
	{
		$count = $this->getExpiredCdTotals();
		if (!$count) {
			echo 'query expired CD time failed'."\r\n";
			return false;
		}

		$res = $this->cleanCdTime();
		if (!$res) {
			echo 'clean CD time failed'."\r\n";
			return false;
		}
		echo 'clean CD time success, count: '.$count."\r\n";
		return true;
	}

	public function handle($userOrderId = NULL)
	{
		$this->expired();
		echo '数据查询完毕！'."\r\n";
		return true;
	}
}